import random


import numpy as np

import pyqtgraph as pg
from pyqtgraph.Qt import QtCore

app = pg.mkQApp("Plotting Example")
#mw = QtWidgets.QMainWindow()
#mw.resize(800,800)

win = pg.GraphicsLayoutWidget(show=True, title="Basic plotting examples")
win.resize(1000,600)
win.setWindowTitle('pyqtgraph example: Plotting')

# Enable antialiasing for prettier plots
pg.setConfigOptions(antialias=True)


if __name__ == '__main__':
    # for _ in range(30):
    #     print(random.gauss(10, 5))
    arr = [random.gauss(10, 5) for _ in range(1000)]
    # 转成numpy数组
    arr = np.array(arr)
    
    # arr转成个数统计直方图stat_arr，x间隔为1
    stat_arr = np.histogram(arr, bins=20, range=(0, 20))
    
    # p1 = win.addPlot(title="Basic array plotting", y=np.random.normal(size=100))
    # p1 = win.addPlot(title="Basic array plotting", y=arr)
    win.addPlot(title="Basic array plotting", y=stat_arr[0], x=stat_arr[1][1:])
        
    pg.exec()
